/**
 * Copyright (C) 2009 Fsti Inc.
 *
 */
package com.fsti.ppmw.port.payment;

import org.apache.log4j.Logger;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

/**
 * 日志
 * 
 * @author Song Qing
 *
 */

@Aspect
public class LogAspect {
	/**
	* 日志
	*/
	private static final Logger logger = Logger.getLogger(LogAspect.class);

	/**
	 * 【调用支付平台web服务】切入点
	 * @param requestParams
	 */
	@Pointcut("execution(* com.fsti.ppmw.port.payment.APServicesClient.call(..)) &&" + "args(requestParams,paymentDAO)")
	public void aPServicesClient(RequestParams requestParams, PaymentDAO paymentDAO) {
	};

	/**
	 * 【调用支付平台web服务】异常返回时，记录日志
	 * @param requestParams
	 * @param ex
	 */
	@AfterThrowing(pointcut = "aPServicesClient(requestParams,paymentDAO)", throwing = "ex")
	public void logException(RequestParams requestParams, PaymentDAO paymentDAO, Exception ex) {
		logger.info("                   ");
		logger.error("请求参数：" + requestParams);
		logger.error("调用支付平台接口服务发生异常！", ex);
	};

	/**
	 * 【调用支付平台web服务】正常返回时，记录日志
	 * @param requestParams
	 * @param retVal
	 */
	@AfterReturning(pointcut = "aPServicesClient(requestParams,paymentDAO)", returning = "retVal")
	public void logNormal(RequestParams requestParams, PaymentDAO paymentDAO, Object retVal) {
		logger.info("                   ");
		logger.info("请求参数：" + requestParams);
		String value = (String) retVal;
		logger.info("返回参数：" + value);
	}
}
